<#list database.tables as table>

<#-- 一个很笨的方法 = =# -->
<#if table.sliceNum <= 1>
<#assign table_suffix = "">
<#elseif table.sliceNum < 10 >
<#assign table_suffix>_&</#assign>
<#elseif table.sliceNum < 100 >
<#assign table_suffix>_&&</#assign>
<#elseif table.sliceNum < 1000 >
<#assign table_suffix>_&&&</#assign>
<#elseif table.sliceNum < 10000 >
<#assign table_suffix>_&&&&</#assign>
</#if>

DROP TABLE IF EXIST ${table.tableName}${table_suffix};
CREATE TABLE ${table.tableName}${table_suffix}
{
	<#assign primary_key="" >
	<#assign is_first="true" />
	<#list table.fields as field>
	${field.sqlFieldName} ${field.type.sqlTypeName} <#if field.unique >UNIQUE</#if>;
	<#if field.primary >
	  <#if is_first=="false" >
	    <#assign primary_key>${primary_key},${field.sqlFieldName}</#assign>
	  <#else>
	    <#assign primary_key>${field.sqlFieldName}</#assign>
	    <#assign is_first="false" >
	  </#if>
	</#if>
	</#list>
	<#if primary_key!="" >
	PRIMARY KEY(${primary_key});
	</#if>
};

</#list>